package dkm;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 * This JUnit test makes sure that efficientRightTurn is doing what it should do.
 * That is, choose the shortest way to turn in a given direction.
 * @author David Mau
 */
public class TestEfficientRightTurn {

  /**
   * Test to see if the method does nothing if the angle calculated needs no modifications.
   */
  @Test
  public void testNoChangeNeeded() {
    PersonalWall robot = new PersonalWall();
    assertEquals( "Testing angle that needs no modifications.",
        robot.efficientRightTurnTo( 0.0, 179.0 ), 179.0, 0.0 );
    assertEquals( "Testing another angle that needs no modifications.",
        robot.efficientRightTurnTo( 0.0, 1.0 ), 1.0, 0.0 );
  }
  
  /**
   * Test to see if the method is simplifying by subtraction properly.
   */
  @Test
  public void testSubtractSimplify() {
    PersonalWall robot = new PersonalWall();
    assertEquals( "Testing angle that will be simplified by subtraction.",
        robot.efficientRightTurnTo( 0.0, 359.0 ), -1.0, 0.0 );
    assertEquals( "Testing another angle that needs simplification by subtraction.",
        robot.efficientRightTurnTo( 0.0, 181.0 ), -179.0, 0.0 );
  }
  
  /**
   * Test to see if the method is simplifying by addition properly.
   */
  @Test
  public void testAdditionSimplify() {
    PersonalWall robot = new PersonalWall();
    assertEquals( "Testing angle that will be simplified by addition.",
        robot.efficientRightTurnTo( 359.0, 0.0 ), 1.0, 0.0 );
    assertEquals( "Testing another angle that needs simplification by subtraction.",
        robot.efficientRightTurnTo( 359.0, 178.0 ), 179.0, 0.0 );
  }
  
}
